import Tracker from '../utils/trackSDK'

export function timing () {

  let FMP, LCP
  new PerformanceObserver((enterlist, observer) => {
    let perfEntries = enterlist.getEntries()
    FMP = perfEntries[0]
    observer.disconnect()
  }).observe({ entryTypes: ['element'] })

  onload(function () {
    setTimeout(() => {
      console.log(111111, performance)
      const { fetchStart, connectStart, connectEnd, requestStart, responseStart, responseEnd, loadEventStart, loadEventEnd, domLoading } = performance.timing

      let data = {
        kind: 'experience',
        type: 'timing',
        connectTime: connectEnd - connectStart,
        ttfbTime: responseStart - requestStart, // 首字节
        responseTime: responseEnd - responseStart, // 
        parseDomTime: loadEventStart - domLoading, // DOM解析时间
      }
    }, 3000);
  })

}